package com.example.dazuoye.service.impl;

import com.example.dazuoye.mapper.ManageMapper;
import com.example.dazuoye.mapper.ManageMapper;
import com.example.dazuoye.model.Car;
import com.example.dazuoye.model.User;
import com.example.dazuoye.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ManageServiceimpl implements ManageService {
    @Autowired
    private ManageMapper manageMapper;

    public void deluser(String u_id)
    {
        manageMapper.removeuseritem(u_id);
        manageMapper.removevipitem(u_id);
        manageMapper.removewalletitem(u_id);
    }

    @Override
    public Car quickgetcarinfo(String carnum) {
        return manageMapper.quickgetcarinfo(carnum);
    }

    public void setqrcode(int c_id, String qrcode) {
        manageMapper.setqrcode(c_id,qrcode);
    }

    public String getpasswd(String uname) {
        return manageMapper.getpasswd(uname);
    }

    public int getcid(String carnum) {
        return manageMapper.getcid(carnum);
    }

    public List<User> getalluser() {
        return manageMapper.getalluser();
    }

    public void insertcar(String carnum,String color,String model,String qrcode,int numseat,String brand,String carpicurl,String carsite)
    {
        manageMapper.newcar(carnum,color,model,qrcode,numseat,brand,carpicurl,carsite);
        int c_id=manageMapper.getcid(carnum);
        manageMapper.newcarusing(c_id,0);
    }

    @Override
    public void uploadcarpic(String carnum, String carpicurl) {
        manageMapper.uploadcarpic(carnum, carpicurl);
    }

    public void acceptuser(String u_id) {
        manageMapper.acceptuser(u_id);
    }

    public void delcar(int c_id) {
        manageMapper.removecar(c_id);
        manageMapper.removeusing(c_id);
    }

    public void distributecoupon(String u_id) {
        manageMapper.distributecoupon(u_id);
    }
}
